package com.example.eurekaprovide;

        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.beans.factory.annotation.Value;
        import org.springframework.cloud.client.ServiceInstance;
        import org.springframework.cloud.client.discovery.DiscoveryClient;
        import org.springframework.web.bind.annotation.RequestMapping;
        import org.springframework.web.bind.annotation.RequestMethod;
        import org.springframework.web.bind.annotation.RestController;

        import java.util.List;

@RestController
@RequestMapping("/provide")
public class ProvideController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public String index(){
        List<ServiceInstance> list = discoveryClient.getInstances("provide-service");
        for(ServiceInstance instance:list){
            System.out.println(list.size()+":"+instance.getHost()+":"+instance.getServiceId()+":"+instance.getPort());
        }
        return "service provide";
    }
}
